const express = require('express')
const { send } = require('process')
const app = express()
const port = 5000

app.use((request, response, next) => {
    console.log('有人请求8000服务器了！')
    console.log('请求的资源是', request.path)
    console.log('请求的来源是', request.get('Host'))
    next()
})
// 定义路由规则
app.get('/cars', (request, response) => {
    const data = [
        {id: 001,name: '奔驰',color: 'black'},
        {id: 002,name: '宝马',color: 'white'},
        {id: 003,name: '大众',color: 'pink'},       
    ]
    response.send(JSON.stringify(data))
})



app.listen(port, () => {
    console.log(`app 服务已经启动，http://localhost:${port} 监听中....`)
})